package com.方法;

import java.util.Scanner;

public class JiSuanQi {
    public static void main(String[] args) {
        while (true){
            System.out.println("请输入运算类型");
            Scanner scanner = new Scanner(System.in);
            String operator = scanner.next();
            if (operator.equals("quit")){
                System.out.println("退出当前计算器");
                break;
            }else {
                System.out.println("请输入计算的两个数");
            }
            Scanner scanner1 = new Scanner(System.in);
            double d1 =scanner1.nextDouble();


            Scanner scanner2 = new Scanner(System.in);
            double d2 =scanner1.nextDouble();

            double result = 0;
            switch (operator){
                case "+":
                    result = add(d1,d2);
                    break;
                case "-":
                    result = sub(d1,d2);
                case "*":
                    result = mul(d1,d2);
                case "/":
                    result = div(d1,d2);

                default:
                    System.out.println("请重新输入");
            }
            System.out.println(d1+operator+d2+"="+result);
        }

    }
    public static double add(double a, double b){
        return a + b;
    }
    public static double sub(double a,double b){
        return a-b;
    }
    public static double mul(double a,double b){
        return a*b;
    }
    public static double div(double a,double b){
        return a/b;
    }

}
